package org.come.bean;

import java.math.BigDecimal;
import java.util.List;
import org.come.entity.TeamRole;

public class TeamBean {
	private BigDecimal teamId;
	private List<TeamRole> teams;
	private String eTeam;
	private String eTask;
	private String eMsg;

	public TeamBean() {
	}

	public boolean upTeamRole(TeamRole role, int type) {
		int i;
		int i1;
		int length;
		TeamRole teamRole;
		if (type == 0) {
			i1 = 0;

			for(length = this.teams.size(); i1 < length; ++i1) {
				teamRole = this.teams.get(i1);
				if (teamRole.getRoleId().compareTo(role.getRoleId()) == 0) {
					i1 = teamRole.getState();
					teamRole.upTeamRole(role);
					return i1 != teamRole.getState();
				}
			}

			this.teams.add(role);
			return true;
		} else if (type == 1) {
			i1 = 0;

			for(length = this.teams.size(); i1 < length; ++i1) {
				teamRole = this.teams.get(i1);
				if (teamRole.getRoleId().compareTo(role.getRoleId()) == 0) {
					this.teams.remove(i1);
					return true;
				}
			}

			return false;
		} else {
			if (type == 2) {
				TeamRole captain = this.teams.get(0);
				TeamRole nCaptain = null;
				int index = -1;
				i1 = 1;

				for(int length1 = this.teams.size(); i1 < length1; ++i1) {
					TeamRole teamRole1 = this.teams.get(i1);
					if (teamRole1.getRoleId().compareTo(role.getRoleId()) == 0) {
						index = i1;
						nCaptain = teamRole1;
						break;
					}
				}

				if (nCaptain != null) {
					nCaptain.upTeamRole(role);
					captain.setState(0);
					this.teams.set(0, nCaptain);
					this.teams.set(index, captain);
					return true;
				}
			}

			return false;
		}
	}

	public BigDecimal getTeamId() {
		return this.teamId;
	}

	public void setTeamId(BigDecimal teamId) {
		this.teamId = teamId;
	}

	public List<TeamRole> getTeams() {
		return this.teams;
	}

	public void setTeams(List<TeamRole> teams) {
		this.teams = teams;
	}

	public String geteTeam() {
		return this.eTeam;
	}

	public void seteTeam(String eTeam) {
		this.eTeam = eTeam;
	}

	public String geteTask() {
		return this.eTask;
	}

	public void seteTask(String eTask) {
		this.eTask = eTask;
	}

	public String geteMsg() {
		return this.eMsg;
	}

	public void seteMsg(String eMsg) {
		this.eMsg = eMsg;
	}
}
